package ar.edu.unq.tpi.uis.tepe3.dominio;

import java.util.ArrayList;
import java.util.List;

/*
 * Existen carpetas, que forman una estructura arborea.
Hay una carpeta root, y debajo múltiples niveles de carpetas hijas.
El sistema debe permitir crear, borrar y editar carpetas.
 * */

public class Folder {
	
	private String name;
	
	private List<Folder> ruta;
	
	private Folder father;
	private List<Folder> daughters;
	
	public Folder(String aName) {
		super();
		this.name = aName;
	}

	public Folder(Folder elfather){
		super();
		this.setFather(elfather);
		this.ruta = this.getRoute();
	}
	/**
	 * @param father the father to set
	 */
	public void setFather(Folder father) {
		this.father = father;
		this.ruta = this.getRoute();
	}

	/**
	 * @return the father
	 */
	public Folder getFather() {
		return father;
	}

	/**
	 * @param daughters the daughters to set
	 */
	public void setDaughters(List<Folder> daughters) {
		this.daughters = daughters;
	}

	/**
	 * @return the daughters
	 */
	public List<Folder> getDaughters() {
		return daughters;
	}

	/*metodos*/
	public void move(Folder destination){
		this.setFather(destination);
		
	}
	
	public Boolean isRoot(){
		return this.father.equals(null);
	}
	
	public List<Folder> getRoute(){
		
		List<Folder> ret = new  ArrayList();
		
		if (!this.isRoot()) {
			ret.addAll(this.father.getRoute());
		}
		
		ret.add(this);
		return ret;
	}
	
	public void addDoughter(Folder aChild){
		this.daughters.add(aChild);
	}
}
